package com.legal.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.legal.exception.CommonException;
import lombok.Getter;

@Getter
public enum UserStatus {
    FROZEN(1, "停用/禁用"),
    NORMAL(0, "正常/启用"),
    ;
    @EnumValue
    final
    int value;
    @JsonValue
    final
    String desc;

    UserStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static UserStatus of(int value) {
        if (value == 1) {
            throw new CommonException(CommonExceptionEnums.USER_LOCKED);
        }
        return NORMAL;
    }
}